package zuoye_3_10;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

/*
 * 1.创建一个arraList集合,并添加以下字符串,字符串中前面是姓名 ,后面是年龄
 *  "zhangsn,23"
 *  "lisi,24"
 *  "wangwu,25"
 *  保留年龄大于24岁的,并将结果收集到map集合中,姓名为建,年龄为值  

	ArrayList<String> arr=new ArrayList();
	Collections.addAll(arr, "张三,21", "李四,24", "丁真,26", "珍珠,27", "锐刻五,30");
*/
public class Zuoye_1 {
	public static void main(String[] args) {
		ArrayList<String> arr=new ArrayList();
		Collections.addAll(arr, "张三,21", "李四,24", "丁真,26", "珍珠,27", "锐刻五,30");
		Map<String, Integer> map = new HashMap<>();
		for(String s:arr) {
			 String[] parts = s.split(",");
	            int age = Integer.parseInt(parts[1]);
	            if (age > 24) {
	                map.put(parts[0], age);
	            }
		}
		System.out.println(map);
	}
}
